package dti;

import java.io.File;

import common.Constants;

/**
 * This class represents an input file. It is used mainly to store information
 * about a file concerning characters and words.
 * 
 * @author Andrew Bernard
 */
public class IndexedFile {

  /** File that this object represents */
  private File file;

  /** Word count of file */
  private int wordCount;

  /** Bitmask of the words chosen to be indexed */
  private long bitmask;

  /**
   * Constructor
   */
  public IndexedFile(File file) {
    this.file = file;
  }

  /**
   * Get this file's bitmask
   */
  public long getBitmask() {
    return bitmask;
  }  

//  /**
//   * Gets total number of characters in this file. Does NOT
//   * care which words were indexed or not.
//   */
//  public long getCharCount() {
//    return file.length();
//  }

//  /**
//   * Sets the number of words in this file.
//   */
//  public void setWordCount(int wordCount) {
//    this.wordCount = wordCount;
//  }
//
//  /**
//   * Returns the number of words in this file. The word count must be set
//   * explicitly at some point before calling this method or the word count
//   * will just be 0.
//   */
//  public int getWordCount() {
//    return wordCount;
//  }

  /**
   * The file on the file system represented by this object
   */
  public File getFile() {
    return file;
  }
  
  /**
   * Processes a word, setting the appropriate bits in the line's bitmask
   * @param    line    Line to add to
   * @param    word    Word to add
   */
  public void addWordToBitmask(String word) {
    int bitOne = Math.abs(word.hashCode() % Constants.DEFAULT_BITS_PER_BITMASK);
    int bitTwo = Math.abs((word.hashCode() * 2) % Constants.DEFAULT_BITS_PER_BITMASK);
    int bitThree = Math.abs((word.hashCode() / 2) % Constants.DEFAULT_BITS_PER_BITMASK);

    bitmask = bitmask | (1 << bitOne);
    bitmask = bitmask | (1 << bitTwo);
    bitmask = bitmask | (1 << bitThree);
  }

}
